package com.lemon.reggie.validator;

import cn.hutool.core.util.StrUtil;
import com.lemon.reggie.annotation.NotValue;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * 自定义校验器
 * @author Guannankun
 * @since 2022/8/15
 */
public class NotValueConstraintValidator implements ConstraintValidator<NotValue, String> {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return StrUtil.isNotBlank(value) && !Objects.equals("[]", value);
    }
}
